<?php
/*
 * *********************************************************
 * ## Module controllers must extend MD_Controller class ##
 * *********************************************************
 */
class Maintenance extends MD_Controller {
    
public function __construct()
{
    parent::__construct();

	/*
	 * ******************************************************************
	 * CHECK IF MODULE IS INSTALLED PROPERLY
	 * ******************************************************************
	 */
	$this->MODULE->config->load('module_config');	
	$short_name = $this->MODULE->config->item('short_name');
	$settings_table = $this->MODULE->config->item('settings_table');	 
	if(!$this->PACKAGE->security->app_modules->module_exist($short_name) || empty($short_name) || empty($settings_table))
	{
		$this->PACKAGE->errors->generate->code("001")->stop();
	}
    
            /*
             * ********************************************
             * LOAD LANGUAGE FILES FOR THIS MODULE ONLY
             * notice that some language files have been
             * loaded within MY_Controller core class
             * and those language files are common for all
             * modules
             * ********************************************
             */    
    
            $this->MODULE->lang->load('module_texts',LANGUAGE);
            
            /*
             * ********************************************
             * LOAD PACKAGES
             * ********************************************
             */
            $this->PACKAGE->core->packages->add('regional');   
			$this->PACKAGE->core->packages->add('routing');   
      
			/*
			 * ********************************************
			 * LOAD LIBRARIES
			 * ********************************************
			 */
			$this->PACKAGE->routing->load->library('carriers/carriers');
			$this->PACKAGE->routing->load->library('trunks/trunks');

			$this->APPLICATION->load->library('app_carriers');
			$this->APPLICATION->load->library('app_trunks');
			$this->APPLICATION->load->library('app_codecs');
			
	  
            /*
             * ********************************************
             * LOAD MODELS
             * ********************************************
             */
			$this->MODULE->load->model('module_mod_settings');
			
            $this->PACKAGE->regional->load->model('countries');
			$this->PACKAGE->regional->load->model('currencies');
            $this->PACKAGE->regional->load->model('timezone');
						
			$this->APPLICATION->load->model('app_mod_cron');
			
			
			//$this->MODULE->load->library('module_translate');			           
}
    

public function update_final_routing_statuses()
{
	$response = $this->APPLICATION->app_mod_cron->update_final_routing_statuses();
	
	$text = '['.date('m-d-Y -- g:i:s a',time()) . ']<br />';
	if($response)
	{
		$text .= lang('msg_cron_executed_successfully');
	}
	
	print $text;
}
	
}


?>
